package controllers

import (
	"beego/mongo"
	"github.com/astaxie/beego"
)

type GetWordController struct {
	beego.Controller
}

var countMap = make(map[string]int)

func (c *GetWordController) Get() {
	class := c.Ctx.Input.Param(":class")
	mongo.MgoCli()
	count = countMap[class]
	count++

	if count > mongo.MongoCountWord(class) {
		countMap[class] = 1
		count = 1
	}
	//mongo.SetManyWords()
	countMap[class] = count
	c.Data["json"] = mongo.GetWord(count, class)[0]
	c.ServeJSON()
}
